package com.yyds.blackmagic.controller;

import com.yyds.blackmagic.entity.AdminMenu;
import com.yyds.blackmagic.service.AdminMenuService;
import com.yyds.blackmagic.utils.JwtUtils;
import com.yyds.blackmagic.vo.ActionResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author ccc
 * @Date 2021/12/16
 * @Descripton
 */
@RestController
@RequestMapping("/api")
@Slf4j
public class AdminMenuController {
    @Autowired
    AdminMenuService adminMenuService;
    @GetMapping("/menu")
    public ActionResult menu (@RequestHeader("token") String token) {
        String username = JwtUtils.getUserInfo (token);
        List<AdminMenu> menulist = adminMenuService.findByUsername (username);
        return new ActionResult (200, "menu",menulist);
    }
}
